#include "mainwindow.h"

MainWindow::MainWindow(QWidget * parent)
	: QMainWindow(parent)
{
	this->setWindowTitle("主窗口演示");
	this->setMinimumSize(500,500);
	createMenu();
    createToolBar();
}
MainWindow::~MainWindow()
{
}
void MainWindow::createAction(){
	openFileAction =new QAction("打开"); // 文件选项
	openFileAction->setShortcut(tr("Ctrl+O"));
	openFileAction->setStatusTip("打开文件");
	newFileAction =new QAction("新建");
	exitAction =new QAction("退出");     // 编辑选项
	copyAction =new QAction("复制");
	copyAction->setShortcut(tr("Ctrl+C"));
	copyAction->setStatusTip("复制文件");
}
void MainWindow::createMenu(){
	menuBar =new QMenuBar(this);
	createAction();   //初始化动作
	FileMenu =new QMenu("文件");
	//文件菜单
	FileMenu->addAction(openFileAction);
	FileMenu->addAction(newFileAction);
	FileMenu->addAction(exitAction);
	menuBar->addMenu(FileMenu);
	this->setMenuBar(menuBar);
	//编辑菜单
	zoomMenu =new QMenu("编辑");
	zoomMenu->addAction(copyAction);
	menuBar->addMenu(zoomMenu);
}
void MainWindow::createToolBar() {
    fileTool = addToolBar("file");
    fileTool->addAction(openFileAction);
    fileTool->addAction(newFileAction);
    fileTool->addAction(printFileAction);
    //fileTool->addAction();

}